<!DOCTYPE html>
<!--
  The MIT License (MIT)

  Copyright (c) 2017 Tarek Sherif

  Permission is hereby granted, free of charge, to any person obtaining a copy of
  this software and associated documentation files (the "Software"), to deal in
  the Software without restriction, including without limitation the rights to
  use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  the Software, and to permit persons to whom the Software is furnished to do so,
  subject to the following conditions:

  The above copyright notice and this permission notice shall be included in all
  copies or substantial portions of the Software.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-->
<!-- 
    DOF algorithm from http://www.nutty.ca/?page_id=352&link=depth_of_field
 -->
<html>
<head>
    <title>WebGL 2 Example: Depth of Field</title>
    <meta charset="utf-8">
    <script src="utils/gl-matrix.js"></script>
    <script src="utils/utils.js"></script>
    <link rel="stylesheet" href="css/webgl2examples.css">
</head>
<body>
    <div id="example-title">
        <header>WebGL 2 Example: Depth of Field</header>
        <div id="features">
            Features: Vertex Arrays, Uniform Buffers, Immutable Textures, Depth Textures, texelFetch, Hardware Instancing
        </div>
        <div>
            <a href="https://github.com/tsherif/webgl2examples/blob/master/dof.html">Source code</a>
        </div>
    </div>
    <canvas id="gl-canvas"></canvas>
    <script type="x-shader/vs" id="vertex-boxes">
        #version 300 es

        layout(std140, column_major) uniform;
        
        layout(location=0) in vec4 position;
        layout(location=1) in vec2 uv;
        layout(location=2) in vec3 normal;
        layout(location=3) in mat4 modelMatrix;
        
        uniform SceneUniforms {
            mat4 uViewProj;
            vec4 uEyePosition;
            vec4 uLightPosition;
        };       
        
        out vec3 vPosition;
        out vec2 vUV;
        out vec3 vNormal;
        void main() {
            vec4 worldPosition = modelMatrix * position;
            vPosition = worldPosition.xyz;
            vUV = uv;
            vNormal = mat3(modelMatrix) * normal;
            gl_Position = uViewProj * worldPosition;
        }
    </script>
    <script type="x-shader/fs" id="fragment-boxes">
        #version 300 es
        precision highp float;

        layout(std140, column_major) uniform;

        uniform SceneUniforms {
            mat4 uViewProj;
            vec4 uEyePosition;
            vec4 uLightPosition;
        };

        uniform sampler2D uTexture;
        
        in vec3 vPosition;
        in vec2 vUV;
        in vec3 vNormal;

        out vec4 fragColor;
        void main() {
            vec3 color = texture(uTexture, vUV).rgb;

            vec3 normal = normalize(vNormal);
            vec3 eyeVec = normalize(uEyePosition.xyz - vPosition);
            vec3 incidentVec = normalize(vPosition - uLightPosition.xyz);
            vec3 lightVec = -incidentVec;
            float diffuse = max(dot(lightVec, normal), 0.0);
            float highlight = pow(max(dot(eyeVec, reflect(incidentVec, normal)), 0.0), 100.0);
            float ambient = 0.1;
            fragColor = vec4(color * (diffuse + highlight + ambient), 1.0);
        }
    </script>
    <script type="x-shader/vs" id="vertex-quad">
        #version 300 es

        layout(location=0) in vec4 aPosition;
        
        void main() {
            gl_Position = aPosition;
        }
    </script>
    <script type="x-shader/fs" id="fragment-blur">
        #version 300 es
        precision highp float;

        layout(std140, column_major) uniform;

        #define MAX_BLUR 20.0

        uniform DOFUniforms {
            float uFocusDistance;
            float uBlurCoefficient;
            float uPPM;
            vec2  uDepthRange; 
            vec2 uResolution;
       };
        
        uniform vec2 uTexelOffset;

        uniform sampler2D uColor;
        uniform sampler2D uDepth;
        
        out vec4 fragColor;

        void main() {
            ivec2 fragCoord = ivec2(gl_FragCoord.xy);
            ivec2 resolution = ivec2(uResolution) - 1;

            // Convert to linear depth
            float ndc = 2.0 * texelFetch(uDepth, fragCoord, 0).r - 1.0;
            float depth = -(2.0 * uDepthRange.y * uDepthRange.x) / (ndc * (uDepthRange.y - uDepthRange.x) - uDepthRange.y - uDepthRange.x);
            float deltaDepth = abs(uFocusDistance - depth);
            
            // Blur more quickly in the foreground.
            float xdd = depth < uFocusDistance ? abs(uFocusDistance - deltaDepth) : abs(uFocusDistance + deltaDepth);
            float blurRadius = min(floor(uBlurCoefficient * (deltaDepth / xdd) * uPPM), MAX_BLUR);
            
            vec4 color = vec4(0.0);
            if (blurRadius > 1.0) {
                float halfBlur = blurRadius * 0.5;

                float count = 0.0;

                for (float i = 0.0; i <= MAX_BLUR; ++i) {
                    if (i > blurRadius) {
                        break;
                    }

                    // texelFetch outside texture gives vec4(0.0) (undefined in ES 3)
                    ivec2 sampleCoord = clamp(fragCoord + ivec2(((i - halfBlur) * uTexelOffset)), ivec2(0), resolution);
                    color += texelFetch(uColor, sampleCoord, 0);

                    ++count;
                }

                color /= count;
            } else {
                color = texelFetch(uColor, fragCoord, 0);
            }

            fragColor = color;
        }
    </script>
    <script>
        var canvas = document.getElementById("gl-canvas");
        canvas.width = window.innerWidth;
        canvas.height = window.innerHeight;

        var gl = canvas.getContext("webgl2");

        if (!gl) {
            console.error("WebGL 2 not available");
            document.body.innerHTML = "This example requires WebGL 2 which is unavailable on this system."
        }

        gl.clearColor(0.0, 0.0, 0.0, 1.0);
        gl.enable(gl.DEPTH_TEST);

        var resolution = vec2.fromValues(gl.drawingBufferWidth, gl.drawingBufferHeight);

        /////////////////////
        // DOF CONSTANTS
        /////////////////////

        var NEAR = 0.1;
        var FAR = 10.0;
        var FOCAL_LENGTH = 1.0;
        var FOCUS_DISTANCE = 2.0;
        var MAGNIFICATION = FOCAL_LENGTH / Math.abs(FOCUS_DISTANCE - FOCAL_LENGTH);
        var FSTOP = 2.8;
        var BLUR_COEFFICIENT = FOCAL_LENGTH * MAGNIFICATION / FSTOP;
        var PPM = Math.sqrt(canvas.width * canvas.width + canvas.height * canvas.height) / 35;   
        var DEPTH_RANGE = vec2.fromValues(NEAR, FAR);

        /////////////////////////
        // OBJECT DESCRIPTIONS
        /////////////////////////

        var NUM_ROWS = 5;
        var BOXES_PER_ROW = 20;
        var NUM_BOXES = BOXES_PER_ROW * NUM_ROWS;
        var boxes = new Array(NUM_BOXES);

        var boxI = 0;
        for (var j = 0; j < NUM_ROWS; ++j) {
            var rowOffset = (j - Math.floor(NUM_ROWS / 2));
            for (var i = 0; i < BOXES_PER_ROW; ++i) {
                boxes[boxI] = {
                    scale: [0.9, 0.9, 0.9],
                    rotate: [-boxI / Math.PI, 0, boxI / Math.PI],
                    translate: [-i + 2 - rowOffset, 0, -i + 2 + rowOffset],
                    modelMatrix: mat4.create(),
                };

                ++boxI;
            }
        }

        var modelMatrixData = new Float32Array(NUM_BOXES * 16);

        /////////////////////
        // MAIN PROGRAM
        /////////////////////

        var boxVsSource =  document.getElementById("vertex-boxes").text.trim();
        var boxFsSource =  document.getElementById("fragment-boxes").text.trim();
        
        var boxVertexShader = gl.createShader(gl.VERTEX_SHADER);
        gl.shaderSource(boxVertexShader, boxVsSource);
        gl.compileShader(boxVertexShader);

        if (!gl.getShaderParameter(boxVertexShader, gl.COMPILE_STATUS)) {
            console.error(gl.getShaderInfoLog(boxVertexShader));
        }

        var boxFragmentShader = gl.createShader(gl.FRAGMENT_SHADER);
        gl.shaderSource(boxFragmentShader, boxFsSource);
        gl.compileShader(boxFragmentShader);

        if (!gl.getShaderParameter(boxFragmentShader, gl.COMPILE_STATUS)) {
            console.error(gl.getShaderInfoLog(boxFragmentShader));
        }

        var boxProgram = gl.createProgram();
        gl.attachShader(boxProgram, boxVertexShader);
        gl.attachShader(boxProgram, boxFragmentShader);
        gl.linkProgram(boxProgram);

        if (!gl.getProgramParameter(boxProgram, gl.LINK_STATUS)) {
            console.error(gl.getProgramInfoLog(boxProgram));
        }

        /////////////////////
        // DOF PROGRAM
        /////////////////////

        var quadVsSource =  document.getElementById("vertex-quad").text.trim();
        var blurFsSource = document.getElementById("fragment-blur").text.trim();

        var blurVertexShader = gl.createShader(gl.VERTEX_SHADER);
        gl.shaderSource(blurVertexShader, quadVsSource);
        gl.compileShader(blurVertexShader);

        if (!gl.getShaderParameter(blurVertexShader, gl.COMPILE_STATUS)) {
            console.error(gl.getShaderInfoLog(blurVertexShader));
        }

        var blurFragmentShader = gl.createShader(gl.FRAGMENT_SHADER);
        gl.shaderSource(blurFragmentShader, blurFsSource);
        gl.compileShader(blurFragmentShader);

        if (!gl.getShaderParameter(blurFragmentShader, gl.COMPILE_STATUS)) {
            console.error(gl.getShaderInfoLog(blurFragmentShader));
        }

        var blurProgram = gl.createProgram();
        gl.attachShader(blurProgram, blurVertexShader);
        gl.attachShader(blurProgram, blurFragmentShader);
        gl.linkProgram(blurProgram);

        if (!gl.getProgramParameter(blurProgram, gl.LINK_STATUS)) {
            console.error(gl.getProgramInfoLog(blurProgram));
        }

        /////////////////////////
        // GET UNIFORM LOCATIONS
        /////////////////////////

        var sceneUniformsLocation = gl.getUniformBlockIndex(boxProgram, "SceneUniforms");
        gl.uniformBlockBinding(boxProgram, sceneUniformsLocation, 0);

        var modelMatrixLocation = gl.getUniformLocation(boxProgram, "uModel");
        var texLocation = gl.getUniformLocation(boxProgram, "uTexture");

        var dofUniformsLocation = gl.getUniformBlockIndex(blurProgram, "DOFUniforms");
        gl.uniformBlockBinding(blurProgram, dofUniformsLocation, 1);

        var texelOffsetLocation = gl.getUniformLocation(blurProgram, "uTexelOffset");

        var textureLocation = gl.getUniformLocation(blurProgram, "uColor");
        var depthLocation = gl.getUniformLocation(blurProgram, "uDepth");

        ////////////////////////////////
        //  SET UP FRAMEBUFFERS
        ////////////////////////////////

        var boxBuffer = gl.createFramebuffer();
        var hblurBuffer = gl.createFramebuffer();

        gl.bindFramebuffer(gl.FRAMEBUFFER, boxBuffer);
        gl.activeTexture(gl.TEXTURE0);

        var colorTarget = gl.createTexture();
        gl.bindTexture(gl.TEXTURE_2D, colorTarget);
        gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
        gl.texStorage2D(gl.TEXTURE_2D, 1, gl.RGBA8, gl.drawingBufferWidth, gl.drawingBufferHeight);
        gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, colorTarget, 0);

        var depthTarget = gl.createTexture();
        gl.bindTexture(gl.TEXTURE_2D, depthTarget);
        gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
        gl.texStorage2D(gl.TEXTURE_2D, 1, gl.DEPTH_COMPONENT16, gl.drawingBufferWidth, gl.drawingBufferHeight);
        gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, depthTarget, 0);


        gl.bindFramebuffer(gl.FRAMEBUFFER, hblurBuffer);

        var hblurTarget = gl.createTexture();
        gl.bindTexture(gl.TEXTURE_2D, hblurTarget);
        gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
        gl.texStorage2D(gl.TEXTURE_2D, 1, gl.RGBA8, gl.drawingBufferWidth, gl.drawingBufferHeight);
        gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, hblurTarget, 0);

        gl.bindFramebuffer(gl.FRAMEBUFFER, null);
        

        /////////////////////
        // SET UP GEOMETRY
        /////////////////////

        var box = utils.createBox({dimensions: [1.0, 1.0, 1.0]});
        var numVertices = box.positions.length / 3;

        var boxArray = gl.createVertexArray();
        gl.bindVertexArray(boxArray);

        var positionBuffer = gl.createBuffer();
        gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer);
        gl.bufferData(gl.ARRAY_BUFFER, box.positions, gl.STATIC_DRAW);
        gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);
        gl.enableVertexAttribArray(0);

        var uvBuffer = gl.createBuffer();
        gl.bindBuffer(gl.ARRAY_BUFFER, uvBuffer);
        gl.bufferData(gl.ARRAY_BUFFER, box.uvs, gl.STATIC_DRAW);
        gl.vertexAttribPointer(1, 2, gl.FLOAT, false, 0, 0);
        gl.enableVertexAttribArray(1);

        var normalBuffer = gl.createBuffer();
        gl.bindBuffer(gl.ARRAY_BUFFER, normalBuffer);
        gl.bufferData(gl.ARRAY_BUFFER, box.normals, gl.STATIC_DRAW);
        gl.vertexAttribPointer(2, 3, gl.FLOAT, false, 0, 0);
        gl.enableVertexAttribArray(2);

        // Columns of matrix as separate attributes for instancing
        var matrixBuffer = gl.createBuffer();
        gl.bindBuffer(gl.ARRAY_BUFFER, matrixBuffer);
        gl.bufferData(gl.ARRAY_BUFFER, modelMatrixData, gl.DYNAMIC_DRAW);
        gl.vertexAttribPointer(3, 4, gl.FLOAT, false, 64, 0);
        gl.vertexAttribPointer(4, 4, gl.FLOAT, false, 64, 16);
        gl.vertexAttribPointer(5, 4, gl.FLOAT, false, 64, 32);
        gl.vertexAttribPointer(6, 4, gl.FLOAT, false, 64, 48);

        gl.vertexAttribDivisor(3, 1);
        gl.vertexAttribDivisor(4, 1);
        gl.vertexAttribDivisor(5, 1);
        gl.vertexAttribDivisor(6, 1);

        gl.enableVertexAttribArray(3);
        gl.enableVertexAttribArray(4);
        gl.enableVertexAttribArray(5);
        gl.enableVertexAttribArray(6);

        var quadArray = gl.createVertexArray();
        gl.bindVertexArray(quadArray);

        var quadPositionBuffer = gl.createBuffer();
        gl.bindBuffer(gl.ARRAY_BUFFER, quadPositionBuffer);
        gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
            -1, 1,
            -1, -1,
            1, -1,
            -1, 1,
            1, -1,
            1, 1,
        ]), gl.STATIC_DRAW);
        gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);
        gl.enableVertexAttribArray(0);


        //////////////////////
        // SET UP UNIFORMS
        //////////////////////

        var projMatrix = mat4.create();
        mat4.perspective(projMatrix, Math.PI / 2, canvas.width / canvas.height, NEAR, FAR);

        var viewMatrix = mat4.create();
        var eyePosition = vec3.fromValues(1, 1.5, 1);
        mat4.lookAt(viewMatrix, eyePosition, vec3.fromValues(0, 0, 0), vec3.fromValues(0, 1, 0));

        var viewProjMatrix = mat4.create();
        mat4.multiply(viewProjMatrix, projMatrix, viewMatrix);

        var lightPosition = vec3.fromValues(1, 1, 0.5);

        var hTexelOffset = vec2.fromValues(1.0, 0.0);
        var vTexelOffset = vec2.fromValues(0.0, 1.0);

        var sceneUniformData = new Float32Array(24);
        sceneUniformData.set(viewProjMatrix);
        sceneUniformData.set(eyePosition, 16);
        sceneUniformData.set(lightPosition, 20);

        var sceneUniformBuffer = gl.createBuffer();
        gl.bindBufferBase(gl.UNIFORM_BUFFER, 0, sceneUniformBuffer);
        gl.bufferData(gl.UNIFORM_BUFFER, sceneUniformData, gl.STATIC_DRAW);

        var dofUniformData = new Float32Array(8);
        dofUniformData[0] = FOCUS_DISTANCE;
        dofUniformData[1] = BLUR_COEFFICIENT;
        dofUniformData[2] = PPM;
        dofUniformData.set(DEPTH_RANGE, 4); 
        dofUniformData.set(resolution, 6); 

        var dofUniformBuffer = gl.createBuffer();
        gl.bindBufferBase(gl.UNIFORM_BUFFER, 1, dofUniformBuffer);
        gl.bufferData(gl.UNIFORM_BUFFER, dofUniformData, gl.STATIC_DRAW);

        var image = new Image();

        image.onload = function() {

            ///////////////////////
            // BIND TEXTURES
            ///////////////////////

            var texture = gl.createTexture();
            gl.activeTexture(gl.TEXTURE0);
            gl.bindTexture(gl.TEXTURE_2D, texture);

            gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
            gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
            gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR);
            gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT);
            gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT);
            
            var levels = levels = Math.floor(Math.log2(Math.max(this.width, this.height))) + 1;
            gl.texStorage2D(gl.TEXTURE_2D, levels, gl.RGBA8, image.width, image.height);
            gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, image.width, image.height, gl.RGBA, gl.UNSIGNED_BYTE, image);
            gl.generateMipmap(gl.TEXTURE_2D);

            gl.activeTexture(gl.TEXTURE1);
            gl.bindTexture(gl.TEXTURE_2D, colorTarget);

            gl.activeTexture(gl.TEXTURE2);
            gl.bindTexture(gl.TEXTURE_2D, depthTarget);

            gl.activeTexture(gl.TEXTURE3);
            gl.bindTexture(gl.TEXTURE_2D, hblurTarget);

            gl.useProgram(boxProgram);
            gl.uniform1i(texLocation, 0);

            gl.useProgram(blurProgram);
            gl.uniform1i(depthLocation, 2);

            function draw() {

                ////////////////////
                // DRAW BOXES
                ////////////////////

                gl.bindFramebuffer(gl.FRAMEBUFFER, boxBuffer);
                gl.useProgram(boxProgram);
                gl.bindVertexArray(boxArray);

                for (var i = 0, len = boxes.length; i < len; ++i) {
                    boxes[i].rotate[0] += 0.01;
                    boxes[i].rotate[1] += 0.02;

                    utils.xformMatrix(boxes[i].modelMatrix, boxes[i].translate, boxes[i].rotate, boxes[i].scale);
                
                    modelMatrixData.set(boxes[i].modelMatrix, i * 16);
                }

                gl.bindBuffer(gl.ARRAY_BUFFER, matrixBuffer);
                gl.bufferSubData(gl.ARRAY_BUFFER, 0, modelMatrixData);
                gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
                gl.drawArraysInstanced(gl.TRIANGLES, 0, numVertices, boxes.length);


                ////////////////////
                // HORIZONTAL BLUR
                ////////////////////

                gl.bindFramebuffer(gl.FRAMEBUFFER, hblurBuffer);
                gl.useProgram(blurProgram);
                gl.bindVertexArray(quadArray);
                gl.bindBufferBase(gl.UNIFORM_BUFFER, 1, dofUniformBuffer);

                gl.uniform1i(textureLocation, 1);
                gl.uniform2fv(texelOffsetLocation, hTexelOffset);
                gl.drawArrays(gl.TRIANGLES, 0, 6);

                ////////////////////
                // VERTICAL BLUR
                ////////////////////

                gl.bindFramebuffer(gl.FRAMEBUFFER, null);
                gl.bindVertexArray(quadArray);
                gl.uniform1i(textureLocation, 3);
                gl.uniform2fv(texelOffsetLocation, vTexelOffset);
                gl.drawArrays(gl.TRIANGLES, 0, 6);                

                requestAnimationFrame(draw);
            }

            requestAnimationFrame(draw);
            
        }

        image.src = "img/khronos_webgl.png";

    </script>
    <a href="https://github.com/tsherif/webgl2examples" id="github-ribbon"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/365986a132ccd6a44c23a9169022c0b5c890c387/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f7265645f6161303030302e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png"></a>
</body>
</html>
